import 'package:color_dart/RgbaColor.dart';
import 'package:flutter/material.dart';
import 'package:im_flutter_sdk_example/jsonserialize/serve/data.dart';
import 'package:im_flutter_sdk_example/utils/global.dart';

class MainPage extends StatelessWidget {
  final ServeData item;
  MainPage({Key key, this.item}) : super(key: key);
  Widget space(Widget child) {
    return Container(
      margin: EdgeInsets.only(right: 6),
      child: child,
    );
  }

  Widget buildInfo(String title, String src) {
    return Container(
      color: Colors.white,
      padding: EdgeInsets.only(bottom: 12, right: 16),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.start,
        children: [
          SizedBox(
            width: 12,
            height: 12,
            child: Image.asset(
              '$src',
              fit: BoxFit.contain,
            ),
          ),
          Container(
              child: Text('$title',
                  style: TextStyle(color: rgba(68, 68, 68, 1), fontSize: 14)),
              margin: EdgeInsets.only(left: 6)),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
          borderRadius: BorderRadius.only(
              topLeft: Radius.circular(20), topRight: Radius.circular(20))),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            color: Colors.white,
            padding: EdgeInsets.symmetric(vertical: 10, horizontal: 16),
            child:
                Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
              Row(
                children: [
                  Text('${item.serviceName}',
                      style: TextStyle(
                          color: rgba(68, 68, 68, 1),
                          fontSize: 17,
                          fontWeight: FontWeight.bold))
                ],
              ),
            ]),
          ),
          Container(
            color: Colors.white,
            width: G.screenWidth(),
            padding: EdgeInsets.symmetric(horizontal: 14),
            child:
                Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
              item.negotiable == 1
                  ? Text(
                      '面议',
                      style:
                          TextStyle(color: rgba(235, 101, 13, 1), fontSize: 22),
                    )
                  : Text(
                      '¥${item.price}',
                      style:
                          TextStyle(color: rgba(235, 101, 13, 1), fontSize: 22),
                    ),
            ]),
          ),
          Container(
            padding: EdgeInsets.all(16),
            color: Colors.white,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                buildInfo('${item.region}',
                    'lib/assets/images/label/label_position.png'),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
